package com.yc.star.vo;


import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class EmailUtil {

    @Resource
    private  JavaMailSender javaMailSender;

    public  void sendSimpleMail(String email, String authCode) {
        try {
            SimpleMailMessage message = new SimpleMailMessage();
            // 配置发送者邮箱
            message.setFrom("3480732449@qq.com"); //发送邮件的邮箱和发件人
            // 配置接受者邮箱
            message.setTo(email);
            // 配置邮件主题
            message.setSubject("星辰伙伴验证邮件");
            // 配置邮件内容
            message.setText("尊敬的用户:你好!\n 登陆验证码为:" + authCode+"\n"+"     (有效期为3分钟)");//设置邮件的内容
            // 发送邮件
            javaMailSender.send(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
